import request from '@/config/axios'

export function useRoomApi() {
  return {
    // 分页
    getPage: async (params: any) => {
      return await request.get({url: '/yxt/room/page', params})
    },
    // 查询
    getObj: async (id: number) => {
      return await request.get({url: '/yxt/room/get?id=' + id})
    },
    // 创建
    createObj: (data: any) => {
      return request.post({url: '/yxt/room/create', data})
    },
    // 更新
    updateObj: (data: any) => {
      return request.post({url: '/yxt/room/update', data})
    },
    // 删除
    deleteObj: async (id: number) => {
      return await request.delete({url: '/yxt/room/delete?id=' + id})
    },
    // 删除专属空间
    deleteExclusive: async (id: number) => {
      return await request.delete({url: '/yxt/room/exclusive/delete?id=' + id})
    },
    // 列表
    getSimpleList: async (id: number) => {
      return await request.get({url: '/yxt/room/get-simple-list?id=' + id})
    },
    // 开启琴房
    open: (data: any) => {
      return request.post({url: '/yxt/room/open', data})
    },
    // 关闭琴房
    close: (data: any) => {
      return request.post({url: '/yxt/room/close', data})
    },
    // 锁定琴房
    lock: (data: any) => {
      return request.post({url: '/yxt/room/lock', data})
    },
    // 远程开门
    remote: (data: any) => {
      return request.post({url: '/yxt/room/door/remote', data})
    },
    // 常开关
    keep: (data: any) => {
      return request.post({url: '/yxt/room/door/keep', data})
    },
  }
}

export function useRoomTypeApi() {
  return {
    // 查询房间类型分页
    getRoomTypePage: async (params: any) => {
      return await request.get({url: '/yxt/room-type/page', params})
    },
    // 查询房间类型列表
    getRoomTypeList: async () => {
      return await request.get({url: '/yxt/room-type/get-simple-list'})
    },
    // 查询房间类型
    getRoomType: async (id: number) => {
      return await request.get({url: '/yxt/room-type/get?id=' + id})
    },
    // 创建房间类型
    createRoomType: (data: any) => {
      return request.post({url: '/yxt/room-type/create', data})
    },
    // 更新房间类型
    updateRoomType: (data: any) => {
      return request.post({url: '/yxt/room-type/update', data})
    },
    // 删除间类型
    deleteRoomType: async (id: number) => {
      return await request.delete({url: '/yxt/room-type/delete?id=' + id})
    },
  }
}

export function useRoomExclusiveApi() {
  return {
    // 分页
    getPage: async (params: any) => {
      return await request.get({url: '/yxt/roomExclusive/page', params})
    },
    // 编辑
    edit: async (data: any) => {
      return request.post({url: '/yxt/roomExclusive/edit', data})
    },
    // 删除
    deleteExclusive: async (id: number) => {
      return await request.delete({url: '/yxt/roomExclusive/delete?id=' + id})
    },
    // 手动批量导入
    importData: async (data: any) => {
      return request.post({url: '/yxt/roomExclusive/importData', data})
    }
  }
}

export function useRoomExclusiveBanApi() {
  return {
    // 获取专属空间禁用日期列表
    getBanDatePage: async (params: any) => {
      return await request.get({url: '/yxt/roomExclusiveBan/page', params})
    },
    // 新增专属空间禁用日期
    add: async (data: any) => {
      return await request.post({url: '/yxt/roomExclusiveBan/add', data})
    },
    // 删除
    deleteExclusiveBan: async (id: number) => {
      return await request.delete({url: '/yxt/roomExclusiveBan/delete?id=' + id})
    },
  }
}

export function useRoomPasswordApi() {
  return {
    // 获取专属空间禁用日期列表
    getPasswordDatePage: async (params: any) => {
      return await request.get({url: '/yxt/roomPassword/page', params})
    },
    // 新增专属空间禁用日期
    add: async (data: any) => {
      return await request.post({url: '/yxt/roomPassword/add', data})
    },
    // 删除
    deleteExclusivePassword: async (id: number) => {
      return await request.delete({url: '/yxt/roomPassword/delete?id=' + id})
    },
  }
}

export function useRoomExclusiveOpenApi() {
  return {
    // 获取专属空间禁用日期列表
    getOpenPage: async (params: any) => {
      return await request.get({url: '/yxt/roomExclusiveOpen/page', params})
    }
  }
}
